home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / CODA_LIN.{93 < prev    next >
Text File  |  1999-09-17  |  5KB  |  144 lines

  1. /* 
  2.  * Coda File System, Linux Kernel module
  3.  * 
  4.  * Original version, adapted from cfs_mach.c, (C) Carnegie Mellon University
  5.  * Linux modifications (C) 1996, Peter J. Braam
  6.  * Rewritten for Linux 2.1 (C) 1997 Carnegie Mellon University
  7.  *
  8.  * Carnegie Mellon University encourages users of this software to
  9.  * contribute improvements to the Coda project.
  10.  */
  11.  
  12. #ifndef _LINUX_CODA_FS
  13. #define _LINUX_CODA_FS
  14.  
  15. #include <linux/kernel.h>
  16. #include <linux/param.h>
  17. #include <linux/sched.h> 
  18. #include <linux/mm.h>
  19. #include <linux/vmalloc.h>
  20. #include <linux/malloc.h>
  21. #include <linux/wait.h>        
  22. #include <linux/types.h>
  23. #include <linux/fs.h>
  24.  
  25. /* operations */
  26. extern struct inode_operations coda_dir_inode_operations;
  27. extern struct inode_operations coda_file_inode_operations;
  28. extern struct inode_operations coda_ioctl_inode_operations;
  29. extern struct inode_operations coda_symlink_inode_operations;
  30.  
  31. extern struct file_operations coda_dir_operations;
  32. extern struct file_operations coda_file_operations;
  33. extern struct file_operations coda_ioctl_operations;
  34.  
  35. /* operations shared over more than one file */
  36. int coda_open(struct inode *i, struct file *f);
  37. int coda_release(struct inode *i, struct file *f);
  38. int coda_permission(struct inode *inode, int mask);
  39. int coda_revalidate_inode(struct dentry *);
  40.  
  41. /* global variables */
  42. extern int coda_debug;
  43. extern int coda_print_entry;
  44. extern int coda_access_cache;
  45.  
  46. /* this file:  heloers */
  47. static __inline__ struct ViceFid *coda_i2f(struct inode *);
  48. char *coda_f2s(ViceFid *f);
  49. char *coda_f2s2(ViceFid *f);
  50. int coda_isroot(struct inode *i);
  51. int coda_fid_is_volroot(struct ViceFid *);
  52. int coda_fid_is_weird(struct ViceFid *fid);
  53. int coda_iscontrol(const char *name, size_t length);
  54.  
  55. void coda_load_creds(struct coda_cred *cred);
  56. int coda_mycred(struct coda_cred *);
  57. void coda_vattr_to_iattr(struct inode *, struct coda_vattr *);
  58. void coda_iattr_to_vattr(struct iattr *, struct coda_vattr *);
  59. unsigned short coda_flags_to_cflags(unsigned short);
  60. void print_vattr( struct coda_vattr *attr );
  61. int coda_cred_ok(struct coda_cred *cred);
  62. int coda_cred_eq(struct coda_cred *cred1, struct coda_cred *cred2);
  63.  
  64. /* defined in  file.c */
  65. void coda_prepare_openfile(struct inode *coda_inode, struct file *coda_file, 
  66.                struct inode *open_inode,  struct file *open_file,
  67.                struct dentry *open_dentry);
  68. void coda_restore_codafile(struct inode *coda_inode, struct file *coda_file, 
  69.                struct inode *open_inode, struct file *open_file);
  70. int coda_inode_grab(dev_t dev, ino_t ino, struct inode **ind);
  71.  
  72. #define NB_SFS_SIZ 0x895440
  73.  
  74. /* cache.c */
  75. void coda_purge_children(struct inode *, int);
  76. void coda_purge_dentries(struct inode *);
  77.  
  78. /* sysctl.h */
  79. void coda_sysctl_init(void);
  80. void coda_sysctl_clean(void);
  81.  
  82.  
  83. /* debugging masks */
  84. #define D_SUPER     1   /* print results returned by Venus */ 
  85. #define D_INODE     2   /* print entry and exit into procedure */
  86. #define D_FILE      4   
  87. #define D_CACHE     8   /* cache debugging */
  88. #define D_MALLOC    16  /* print malloc, de-alloc information */
  89. #define D_CNODE     32
  90. #define D_UPCALL    64  /* up and downcall debugging */
  91. #define D_PSDEV    128  
  92. #define D_PIOCTL   256
  93. #define D_SPECIAL  512
  94. #define D_TIMING  1024
  95. #define D_DOWNCALL 2048
  96.  
  97. #define CDEBUG(mask, format, a...)                                \
  98.   do {                                                            \
  99.   if (coda_debug & mask) {                                        \
  100.     printk("(%s,l. %d): ",  __FUNCTION__, __LINE__);              \
  101.     printk(format, ## a); }                                       \
  102. } while (0) ;                            
  103.  
  104. #define ENTRY    \
  105.     if(coda_print_entry) printk("Process %d entered %s\n",current->pid,__FUNCTION__)
  106.  
  107. #define EXIT    \
  108.     if(coda_print_entry) printk("Process %d leaving %s\n",current->pid,__FUNCTION__)
  109.  
  110. #define CHECK_CNODE(c) do {  } while (0);
  111.  
  112. #define CODA_ALLOC(ptr, cast, size)                                       \
  113. do {                                                                      \
  114.     if (size < 3000) {                                                    \
  115.         ptr = (cast)kmalloc((unsigned long) size, GFP_KERNEL);            \
  116.                 CDEBUG(D_MALLOC, "kmalloced: %x at %x.\n", (int) size, (int) ptr);\
  117.      }  else {                                                             \
  118.         ptr = (cast)vmalloc((unsigned long) size);                        \
  119.     CDEBUG(D_MALLOC, "vmalloced: %x at %x.\n", (int) size, (int) ptr);}\
  120.     if (ptr == 0) {                                                       \
  121.         printk("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__);  \
  122.     }                                                                     \
  123.     memset( ptr, 0, size );                                                   \
  124. } while (0)
  125.  
  126.  
  127. #define CODA_FREE(ptr,size) do {if (size < 3000) { kfree_s((ptr), (size)); CDEBUG(D_MALLOC, "kfreed: %x at %x.\n", (int) size, (int) ptr); } else { vfree((ptr)); CDEBUG(D_MALLOC, "vfreed: %x at %x.\n", (int) size, (int) ptr);} } while (0)
  128.  
  129. /* inode to cnode */
  130.  
  131. static __inline__ struct ViceFid *coda_i2f(struct inode *inode)
  132. {
  133.     return &(inode->u.coda_i.c_fid);
  134. }
  135.  
  136. #define ITOC(inode) (&((inode)->u.coda_i))
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143. #endif
  144.